package com.hjj.springboot.controller;



import com.hjj.springboot.entity.R;
import com.hjj.springboot.entity.RecommendationDTO;
import com.hjj.springboot.service.RecommendationService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import java.util.HashMap;
import java.util.List;


@RestController
@RequestMapping("/my/recommend")
@RequiredArgsConstructor
public class RecommendationController {

    @Autowired
    private RecommendationService recommendationService;

    /**
     * 获取个性化推荐
     * @param userId 用户ID
     * @param limit 返回数量（默认8）
     */
    @GetMapping("/{userId}")
    public R getPersonalized(
            @PathVariable String userId,
            @RequestParam(required = false, defaultValue = "8") int limit) {

        List<RecommendationDTO> recommendations = recommendationService
                .getPersonalizedRecommendations(userId, limit);

        HashMap<String, Object> map = new HashMap<>();
        map.put("recommendations", recommendations);
        return R.ok(map);
    }


}
